module.exports   A
last analyzed

Complexity

Conditions 1
Paths 2

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 1
c 3
b 0
f 0
nc 2
nop 1
dl 0
loc 16
rs 9.4285
1
/**
2
 * Node
3
 *
4
 * LICENSE:    MIT
5
 *
6
 * @project    node-red-contrib-say
7
 * @package    NodeRedNode
8
 * @author     André Lademann <[email protected]>
9
 * @copyright  Copyright (c) 2014 programmerq.eu (http://programmerq.eu)
10
 * @license    http://programmerq.eu/license
11
 * @since      2014-11-27 - 08:53:21 AM
12
 */
13
module.exports = function (RED) {
14
	'use strict';
15
16
	var say = require('say');
17
18
	/**
19
	 * Say node
20
	 *
21
	 * @property {*} config Configuration object
22
	 * @return void
23
	 **/
24
	function SayNode(config) {
25
		RED.nodes.createNode(this, config);
26
		var node = this;
27
		this.on('input', function (msg) {
28
			say.speak(
29
				this.name || msg.payload,
30
				this.voice,
31
				1,
32
				function(err) {
33
					if (err) {
34
				    return node.error(err);
35
				  }
36
				node.send(msg);
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
37
			});
38
		});
39
	}
40
41
	RED.nodes.registerType('say', SayNode);
42
};
43